<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="nav-header">
			<view class="nav-bar">
				<view class="nav-left" @click="goBack">
					<view class="back-arrow"></view>
				</view>
				<view class="nav-title">领券中心</view>
				<view class="nav-right"></view>
			</view>
		</view>

		<!-- 内容区域 -->
		<view class="content-view">
			<view class="coupon-container">
				<!-- 移除标题区域 -->
				<view class="coupon-scroll">
					<view class="coupon-item" v-for="(coupon, index) in coupons" :key="index">
						<!-- 左侧金额区域 -->
						<view class="coupon-value">
							<view class="amount-container">
								<text class="rmb">¥</text>
								<text class="value">{{ coupon.value }}</text>
							</view>
						</view>

						<!-- 右侧信息区域 -->
						<view class="coupon-info">
							<text class="condition">{{ coupon.condition }}</text>
							<text class="usage">{{ coupon.usage }}</text>
							<text class="date-range">{{ coupon.dateRange }}</text>
							<view class="coupon-action">
								<button
									:class="['action-button', coupon.claimed ? 'claimed' : 'unclaimed']">{{ coupon.claimed ? '已领取' : '领取' }}</button>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';

	const coupons = ref([{
			value: 20,
			condition: '满200元可用',
			usage: '仅限于XX加油站使用',
			dateRange: '2020.04.11—2023.05.11',
			claimed: false
		}, {
			value: 20,
			condition: '满200元可用',
			usage: '仅限于XX加油站使用',
			dateRange: '2020.04.11—2023.05.11',
			claimed: true
		},
		{
			value: 20,
			condition: '满200元可用',
			usage: '仅限于XX加油站使用',
			dateRange: '2020.04.11—2023.05.11',
			claimed: true
		}
	]);

	const goBack = () => {
		uni.navigateBack();
	};
</script>

<style scoped>
	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: #f5f5f5;
		overflow: hidden;
	}



	/* 顶部导航栏 */
	.nav-header {
		background: linear-gradient(180deg, #2477F4 0%, #166BEC 100%);
		padding-top: 30rpx;
		/* 增加底部内边距替代search-placeholder的高度 */
		padding-bottom: calc(30rpx + 250rpx);
	}

	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		padding-top: calc(20rpx + env(safe-area-inset-top));
		position: relative;
	}

	.nav-left {
		width: 80rpx;
		display: flex;
		align-items: center;
		cursor: pointer;
	}

	.back-arrow {
		width: 24rpx;
		height: 24rpx;
		border-left: 4rpx solid #fff;
		border-bottom: 4rpx solid #fff;
		transform: rotate(45deg);
		margin-left: 10rpx;
	}

	.nav-title {
		flex: 1;
		text-align: center;
		font-size: 36rpx;
		font-weight: 500;
		color: #fff;
		position: absolute;
		left: 0;
		right: 0;
		pointer-events: none;
	}

	.nav-right {
		width: 80rpx;
	}



	.content-view {
		padding: 0 30rpx 20rpx 30rpx;
		margin-top: -250rpx;
		overflow: visible;
		display: flex;
		flex-direction: column;
	}

	.coupon-container {
		background: #fff;
		border-radius: 20rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
		display: flex;
		flex-direction: column;
		overflow: hidden;
	}

	/* 移除标题样式 */

	.coupon-scroll {
		width: 100%;
		padding: 20rpx 0;
	}

	.coupon-item {
		display: flex;
		align-items: stretch;
		margin: 20rpx 30rpx;
		border-radius: 12rpx;
		overflow: hidden;
		/* box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1); */
		background-image: url('/static/image/couponCenter/组 5.png');
		background-size: cover;
		background-position: center;
		background-repeat: no-repeat;
		position: relative;
		min-height: 200rpx;
	}

	.coupon-value {
		width: 200rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #FFFFFF;
		font-weight: bold;
		position: relative;
		z-index: 2;
	}

	.amount-container {
		display: flex;
		align-items: baseline;
	}

	.coupon-value .rmb {
		font-size: 32rpx;
		margin-right: 5rpx;
	}

	.coupon-value .value {
		font-size: 64rpx;
		line-height: 1;
	}



	.coupon-info {
		flex: 1;
		padding: 20rpx 160rpx 20rpx 30rpx;
		display: flex;
		flex-direction: column;
		position: relative;
		z-index: 1;
	}

	.coupon-info .condition {
		font-size: 28rpx;
		font-weight: bold;
		color: #FF6E3D;
		margin-bottom: 8rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.coupon-info .usage {
		font-size: 24rpx;
		color: #333333;
		margin-bottom: 8rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.coupon-info .date-range {
		font-size: 20rpx;
		color: #999999;
		margin-top: 20rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.coupon-action {
		position: absolute;
		top: 50%;
		right: 30rpx;
		transform: translateY(-50%);
		z-index: 10;
	}

	.coupon-action .action-button {
		min-width: 120rpx;
		height: 60rpx;
		line-height: 60rpx;
		border-radius: 30rpx;
		font-size: 28rpx;
		padding: 0 20rpx;
	}

	.coupon-action .unclaimed {
		background: #FF6E3D;
		color: #FFFFFF;
	}

	.coupon-action .claimed {
		background: #E0E0E0;
		color: #999999;
	}

	/* 去除按钮默认样式 */
	button {
		border: none;
		background: none;
	}

	button::after {
		border: none;
	}
</style>